package com.company.project.service.impl;

import com.company.project.core.Result;
import com.company.project.core.ResultGenerator;
import com.company.project.dao.ShopInfoMapper;
import com.company.project.model.ShopInfo;
import com.company.project.service.ShopInfoService;
import com.company.project.core.AbstractService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;


/**
 * Created by CodeGenerator on 2020/04/21.
 */
@Service
@Transactional
public class ShopInfoServiceImpl extends AbstractService<ShopInfo> implements ShopInfoService {
    @Resource
    private ShopInfoMapper shopInfoMapper;

    @Override
    public Result editBase(ShopInfo entity) {
        ShopInfo query = new ShopInfo();
        query.setShopId(entity.getShopId());
        ShopInfo shopInfo = shopInfoMapper.selectOne(query);
        shopInfo.setShopName(entity.getShopName());
        shopInfo.setShopKind(entity.getShopKind());
        shopInfo.setContactMan(entity.getContactMan());
        shopInfo.setContactMobile(entity.getContactMobile());
        shopInfo.setSendCost(entity.getSendCost());
        shopInfo.setBoxCost(entity.getBoxCost());
        shopInfo.setAddress(entity.getAddress());
        shopInfoMapper.updateByPrimaryKey(shopInfo);
        return ResultGenerator.genSuccessResult(shopInfo);
    }

    @Override
    public Result editImg(ShopInfo entity) {
        ShopInfo query = new ShopInfo();
        query.setShopId(entity.getShopId());
        ShopInfo shopInfo = shopInfoMapper.selectOne(query);
        shopInfo.setLogoImg(entity.getLogoImg());
        shopInfo.setStoreImg(entity.getStoreImg());
        shopInfo.setInstoreImg(entity.getInstoreImg());
        shopInfoMapper.updateByPrimaryKey(shopInfo);
        return ResultGenerator.genSuccessResult();
    }
}
